package org.example.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.bean.Student;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/second")
@Tag(name = "secondController",description = "这个是对Second操作的用户访问接口")
public class SecondController {
    @GetMapping("/a")
    @Operation(description = "返回了一段内容")
    public Integer a(){
        return 23;
    }
    @GetMapping("/b/{c}")
    @Operation(
            description = "该方法根据用户的选择进行计算操作",
            parameters = {
                    @Parameter(name = "a",required = true,description = "计算中的一个数",in = ParameterIn.QUERY),
                    @Parameter(name = "b",required = true,description = "计算中的另一个数",in = ParameterIn.QUERY),
                    @Parameter(name = "c",required = true,description = "运算类型",in = ParameterIn.PATH)
            },
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "正常返回"
                    ),
                    @ApiResponse(
                            responseCode = "500",
                            description = "数字异常"
                    )
            }
    )
    public Integer b(@RequestParam("a") int a, @RequestParam("b") int b, @PathVariable("c") int c){
        if (c ==1){
            return a+b;
        }else if (c ==2){
            return a-b;
        }else if (c ==3){
            return a*b;
        }else {
            return a/b;
        }
    }
    @GetMapping("/c")
    @Operation(description = "返回学生信息",responses = {
            @ApiResponse(description = "返回结果")
    })
    public Student c(){
        return new Student();
    }

}
